home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / util / cli / cliutils_mra.lha / Sources / RequestChoice / RequestChoice.a < prev    next >
Encoding:
Text File  |  1998-07-16  |  4.2 KB  |  195 lines

  1. ;
  2. ; $VER: RequestChoice.a v36.1 written by Mauro Panigada
  3. ;
  4. ; Started:  1998.07.16
  5. ; Finished: 1998.07.16
  6. ;
  7. ; Requirements: OS2.0 (#36), 020+ (this is 020 version, only for odd addrs, I believe!)
  8. ; Purpose: replace RequestChoice command, so long to me.
  9. ; Note: it is PURE.
  10. ;
  11. ; Usage: TITLE/A,BODY/A,GADGETS,PUBSCREEN/K
  12. ;
  13. ; TITLE: the title of the window
  14. ; BODY: the body text you will read
  15. ; GADGETS: the gadgets: retry|resume or "go on|go down|go up"
  16. ; PUBSCREEN: the name of a pubscreen, if you want
  17. ;
  18. ; Note: * if the given PUBSCREEN does not exist, it open the requester on the default
  19. ;   public screen (ie often Workbench), this behavior is different from the original
  20. ;   RequestChoice (which says "not enough memory available"!)
  21. ; * this RequestChoice, leaves the pressed button also in d0, so you could check it
  22. ;   in startup-sequence as if it is an error (or a condition code returned by a prg)
  23. ; * the way you pass the gadgets in this RequestChoice is different: not as multiple
  24. ;   string but as a sequence of string separated by | (so EasyRequest requires!), and
  25. ;   you can forget it: the default gadgets are "Yes|No" for two ways answer (are you
  26. ;   an Amiga's friend? Yes I am; no I am not.)
  27. ; * return code for a real error (not for gadget) is 30 (put failat 25, for example...
  28. ;   I think it is rare you have more than 24 gadgets!)
  29. ;
  30.  
  31.  
  32.         incdir    "dh0:progr/assem/include/"
  33.         include    "exec/types.i"
  34.         include    "exec/memory.i"
  35.         include    "exec/libraries.i"
  36.         include    "exec/exec_lib.i"
  37.         include    "dos/dos.i"
  38.         include    "dos/dosextens.i"
  39.         include    "dos/dos_lib.i"
  40.         include    "intuition/intuition.i"
  41.         include    "intuition/intuition_lib.i"
  42.  
  43. LIBVERSION    EQU    36
  44.  
  45. CALL        MACRO
  46.         jsr    _LVO\1(a6)
  47.         ENDM
  48.  
  49.     STRUCTURE internal,0
  50.         LONG    execbase
  51.         LONG    oldstack
  52.  
  53.         LABEL    array
  54.         LONG    title
  55.         LONG    body
  56.         LONG    gadgets
  57.         LONG    pubscreen
  58.  
  59.         STRUCT    ERS,EasyStruct_SIZEOF
  60.  
  61.         LONG    returncode
  62.  
  63.         LABEL    s_size        ; word aligned, please
  64.  
  65.  
  66.     SECTION    codice,CODE
  67.  
  68.         opt    p=68020            ; but in old style!
  69.  
  70.         bra.s    start
  71.  
  72.         dc.b    "$VER: RequestChoice 36.1 [020+] (1998.07.16) "
  73.         dc.b    "by Mauro Panigada",13,10
  74.         dc.b    0
  75.         even
  76.  
  77. start        move.l    sp,a0
  78.         move.w    #(s_size/2)-1,d0
  79. lap        clr.w    -(sp)
  80.         dbf    d0,lap
  81.         move.l    sp,a5
  82.         move.l    a0,oldstack(a5)
  83.  
  84.         move.b    #30,returncode+3(a5)
  85.         movea.l    4.w,a6
  86.         move.l    a6,(a5)
  87.         lea    dosname(pc),a1
  88.         moveq    #LIBVERSION,d0
  89.         CALL    OpenLibrary
  90.         move.l    d0,d7            ; d7=dos
  91.         beq    exit
  92.         lea    intname(pc),a1
  93.         moveq    #LIBVERSION,d0
  94.         CALL    OpenLibrary
  95.         move.l    d0,d6            ; d6=intuition
  96.         beq    exit
  97.         move.l    d7,a6
  98.  
  99.         lea    template(pc),a0
  100.         move.l    a0,d1
  101.         move.l    a5,d2
  102.         addq.l    #array,d2
  103.         moveq    #0,d3
  104.         CALL    ReadArgs
  105.         move.l    d0,d5            ; d5=readargs
  106.         beq    argerror
  107.  
  108. main        lea    ERS(a5),a1
  109.         move.l    #EasyStruct_SIZEOF,(a1)
  110.         move.l    body(a5),es_TextFormat(a1)
  111.         lea    stdgad(pc),a0
  112.         move.l    a0,es_GadgetFormat(a1)
  113.         tst.l    gadgets(a5)
  114.         beq.s    okarg0
  115.         move.l    gadgets(a5),es_GadgetFormat(a1)
  116. okarg0        move.l    title(a5),es_Title(a1)
  117.         move.l    a1,-(sp)
  118.  
  119.         moveq    #0,d4
  120.         move.l    d6,a6
  121.         suba.l    a0,a0
  122.         tst.l    pubscreen(a5)
  123.         beq.s    nops
  124.  
  125.         move.l    pubscreen(a5),a0
  126.         CALL    LockPubScreen
  127.         move.l    d0,a0
  128.         move.l    d0,d4            ;d4=screenlock
  129.         beq.s    nops
  130.         move.l    sc_FirstWindow(a0),a0
  131.  
  132. nops        move.l    (sp)+,a1
  133.         suba.l    a2,a2
  134.         suba.l    a3,a2
  135.         CALL    EasyRequestArgs
  136.         move.l    d0,-(sp)
  137.         tst.l    d4
  138.         beq.s    nunl
  139.         move.l    d4,a0
  140.         CALL    UnlockPubScreen
  141. nunl        move.l    d7,a6
  142.         lea    formatstr(pc),a0
  143.         move.l    a0,d1
  144.         move.l    sp,d2
  145.         move.l    (sp),returncode(a5)
  146.         CALL    VPrintf
  147.         addq.l    #4,sp
  148.  
  149. exit0        move.l    d5,d1
  150.         beq.s    exit
  151.         CALL    FreeArgs
  152.  
  153. exit        move.l    d6,a1
  154.         movea.l    4.w,a6
  155.         CALL    CloseLibrary
  156.         move.l    d7,a1
  157.         CALL    CloseLibrary
  158.  
  159.         move.l    returncode(a5),d0
  160.         move.l    oldstack(a5),sp
  161.         rts
  162.  
  163. doserror
  164. argerror    CALL    IoErr
  165.         move.l    d0,d1
  166.         moveq    #0,d2
  167.         CALL    PrintFault
  168.         move.b    #30,returncode+3(a5)
  169.         bra.s    exit0
  170.  
  171. *convert        movem.l    a0/a6,-(sp)
  172. *        movea.l    4.w,a6
  173. *        lea    formatstr(pc),a0
  174. *        lea    stream(pc),a1
  175. *        lea    proc(pc),a2
  176. *        lea    cbuf(pc),a3
  177. *        CALL    RawDoFmt
  178. *        movem.l    (sp)+,a0/a6
  179. *        rts
  180. *proc        move.b    d0,(a3)+
  181. *        rts
  182.  
  183. ;=========================================================================
  184. dosname        dc.b    "dos.library",0
  185. intname        dc.b    "intuition.library",0
  186. *ers        dc.l    EasyStruct_SIZEOF
  187. *        dc.l    0
  188. *        dc.l    0,0,0
  189. template    dc.b    "TITLE/A,BODY/A,GADGETS,PUBSCREEN/K",0
  190. formatstr    dc.b    "%ld"
  191. accapo        dc.b    10,0
  192. stdgad        dc.b    "Yes|No",0
  193.  
  194.  
  195.         END